<template>
    <div id="newDetail">
        <v-swiper :imgGroup="imgGroup"></v-swiper>
        <v-context :data="data"></v-context>
        <v-three :tagGroup="tagGroup"></v-three>
        <v-space></v-space>
        <v-assess :Group="Group"></v-assess>
        <v-space></v-space>
        <v-link :shopGroup="shopGroup"></v-link>
        <v-space></v-space>
        <v-imgDetail :detailsGroup="detailsGroup"></v-imgDetail>
        <!--遮罩层-->
        <div class="templBg" v-if="showTem||this.s==1" @click="Bback"></div>
        <!--随心砍-->
        <!--this.$route.query.show==1-->
        <div class="bb" v-if="cutFree||this.s==1" >
            <p class="p1">随心砍</p>
            <p class="p2" >
                <span class="wtpay">我想付</span>
                <span class="sign">
                    <span @click="goCutFree(item,index)" v-for="(item,index) in randcut" :class="{active:num==index}">￥{{item.cutMoney}}</span>
                </span>
            </p>
            <p class="p3" >
                帮砍人数
                <span v-if="pNum">{{haha.peopleNum}}</span>
                <span v-if="pNum2" >{{randcut[0].peopleNum}}</span>
            </p>
            <div class="p4">
                <p>活动时间24小时，达到砍价人数平台发货，</p>
                <p>未达到自动退款，帮砍仅限新用户参加。</p>
            </div>
            <ul style="display:flex;justify-content: space-between;">
                <li class="btn1" @click="Bback">取消</li>
                <li class="btn2" @click="yep">确定</li>
            </ul>
        </div>
        <!--关闭符号-->
        <div class="styleX" v-if="showTems" @click="Bback">
            <img src="https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/change/close_b.png">
        </div>
        <!--已经发起过砍价的弹框-->
        <div class="newContext" v-if="test">
            <p>{{newContext}}</p>
        </div>
        <!--未关注弹框-->
        <div class="contexts"  v-if="guanzhu">
            <p>关注公众号,帮好友砍更多价格</p>
            <img class="imgLeft" :src="guanzhuInfo.codeUrl">
            <img class="imgRight" :src="guanzhuInfo.imgFinger">
        </div>
        <div class="footer">
            <div class="opction">
                <dl class="home" @click="goSubhome">
                    <dt class="icon1">
                        <img src="https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/home_details@2x.png">
                    </dt>
                    <dd class="homeTest">首页</dd>
                </dl>
                <dl class="message" @click="gozhichi">
                    <dt class="icon2">
                        <img src="https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/customer_service@2x.png">
                    </dt>
                    <dd class="mess">客服</dd>
                </dl>
                <dl class="collection" @click="collection">
                    <dt class="icon3" >
                        <img :src="isCollection==1?'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/collection_details.png':'https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/nocollection_details@2x.png'">
                    </dt>
                    <dd :class="isCollection==1?'changeColor':'love'">{{isCollection?'已收藏':'收藏'}}</dd>
                </dl>
            </div>
            <!--判断商品是否下架的按钮状态-->
            <div v-if="zero">
                <div class="btn" @click="buyNow" v-if="inStock">
                    <ul style="line-height: .4rem;">
                        <li class="money"><span style="font-size:.22rem;margin-right:.08rem;">¥</span>{{skuList[0]["price_max"]}}</li>
                        <li class="buy" >直接购买</li>
                    </ul>
                </div>
            </div>

            <!--判断有无直接购买的按钮样式:style="isCutZero!==2?'width:4.1rem':'width:2.1rem'"-->
            <button class="btn-right" @click="goCut" v-if="inStock" :style="zero==false?'width: 3.2rem;font-size: .32rem;border-radius: .36rem;height: .72rem;margin-right: .28rem;margin-top: .16rem;':''">
                <!--{{isCutZero==1?'砍到1分':isCutZero==2?'砍到'+data.baseInfo.min_shop_price+'元':randcut[0].cutMoney + '元得'}}-->
                {{isCutZero==1?'砍到1分':'砍到'+data.baseInfo.min_shop_price+'元'}}
            </button>
            <!--商品已下架-->
            <div v-if="!inStock" class="noStock" style="width: 4.56rem;background: #969696;color:white;font-size:.32rem;text-align: center;line-height:1rem;">已下架</div>
            <mt-popup v-model="popupVisible" position="bottom" class="alert">
                <div class="buy" >
                    <div class="one">
                        <div class="photo">
                            <div class="my-gallery" :data-pswp-uid="defalutSku.pro_img">
                                <figure>
                                    <img :src="defalutSku.pro_img" @click="photoSwiperInit(defalutSku.pro_img)" >
                                </figure>
                            </div>
                        </div>
                        <ul class="doing">
                            <li class="icon">
								<span>
									<span style="font-size: .3rem;margin-right:.12rem" v-if="lastMoney">
										¥{{moneyMin}}
									</span>
								</span>
                                <span :style="lastMoney==true?'text-decoration: line-through;':''">
									<span v-if="noshowTwo">¥{{moneyMax}}</span>
								</span>
                            </li>
                            <li class="text" v-if="this.tag !=0||this.tag2 !=0" style="-webkit-box-orient: vertical;">已选:<span style="border-radius:0;background: none;padding:0; ">{{checkSku+' '+checkSkuList}}</span></li>
                        </ul>
                        <img @click="goBack" src="https://khh-server.oss-cn-beijing.aliyuncs.com/resourse/IMG/static/close_details@2x.png" style="margin-right:.28rem;margin-top:.28rem;width:.65rem;height:.65rem;border-radius:50%;float:right;">
                    </div>

                    <div id="skuContainer" style="overflow: auto;overflow-x: hidden;height:5.3rem;">
                        <div class="two">
                            <h1>{{oneSpec.name}}</h1><br>
                            <ul class="format" >
                                <li v-for="(y,z) in oneSpec.value" class='nochange' @click="tabCredit($event)"  ref="onelist">{{y.value}}</li>
                            </ul>
                        </div>
                        <div class="two" v-if="twoSpec.name!=''">
                            <h1>{{twoSpec.name}}</h1><br>
                            <ul class="format" >
                                <li v-for="(y,z) in twoSpec.value" class='nochange'  @click="twoCredit($event)"  ref="twolist">{{y.value}}</li>
                            </ul>
                        </div>
                    </div>
                </div>
                <div class="sure" :style="bibibi" @click="buy">{{sureText}}</div>
            </mt-popup>
        </div>
        <!-- Root element of PhotoSwipe. Must have class pswp. -->
        <div class="pswp" tabindex="-1" role="dialog" aria-hidden="true">

            <!-- Background of PhotoSwipe.
                 It's a separate element as animating opacity is faster than rgba(). -->
            <div class="pswp__bg"></div>

            <!-- Slides wrapper with overflow:hidden. -->
            <div class="pswp__scroll-wrap">

                <!-- Container that holds slides.
                    PhotoSwipe keeps only 3 of them in the DOM to save memory.
                    Don't modify these 3 pswp__item elements, data is added later on. -->
                <div class="pswp__container">
                    <div class="pswp__item"></div>
                    <div class="pswp__item"></div>
                    <div class="pswp__item"></div>
                </div>

                <!-- Default (PhotoSwipeUI_Default) interface on top of sliding area. Can be changed. -->
                <div class="pswp__ui pswp__ui--hidden">

                    <div class="pswp__top-bar">

                        <!--  Controls are self-explanatory. Order can be changed. -->

                        <div class="pswp__counter"></div>

                        <button class="pswp__button pswp__button--close" title="Close (Esc)"></button>

                        <button class="pswp__button pswp__button--zoom" title="Zoom in/out"></button>

                        <!-- Preloader demo https://codepen.io/dimsemenov/pen/yyBWoR -->
                        <!-- element will get class pswp__preloader--active when preloader is running -->
                        <div class="pswp__preloader">
                            <div class="pswp__preloader__icn">
                                <div class="pswp__preloader__cut">
                                    <div class="pswp__preloader__donut"></div>
                                </div>
                            </div>
                        </div>
                    </div>

                    <div class="pswp__share-modal pswp__share-modal--hidden pswp__single-tap">
                        <div class="pswp__share-tooltip"></div>
                    </div>

                    <button class="pswp__button pswp__button--arrow--left" title="Previous (arrow left)">
                    </button>

                    <button class="pswp__button pswp__button--arrow--right" title="Next (arrow right)">
                    </button>

                    <div class="pswp__caption">
                        <div class="pswp__caption__center"></div>
                    </div>

                </div>

            </div>

        </div>
    </div>
</template>

<script>
  import store from "../store/newStore.js";
  import Swiper from "./swiper.vue";
  import Context from "./context.vue";
  import Three from "./three.vue";
  import Assess from "./assess.vue";
  import Space from "./space.vue";
  import Link from "./link.vue";
  import Guess from "./guess.vue";
  import ImgDetail from "./imgDetail.vue";
  import { Popup } from 'mint-ui';
  import config from "../config/config.js";
  import share from "../share/share.js";
  import MtaH5 from 'mta-h5-analysis';
  export default{
    data(){
      return{
        popupVisible: false,
        Group:{},
        data:{},
        shopGroup:{},
        tagGroup:Array,
        imgGroup:[],
        hotslide:{},
        detailsGroup:{},
        skuList:[],
        skuId:'',
        proStock:'',
        proId:'',
        type:'',
        isOnline:'',
        isCollection:Boolean,
        proStand:[],
        oneSpec:{},
        twoSpec:[],
        defalutSku:[],
        cuttype:'',
        buy_num:1,
        checkSku:'',
        checkSkuList:'',
        money:'',
        delivery_price:'',
        Popup,
        inStock:true,
        pro_spu:'',
        showTem:false,
        showTems:false,
        test:false,
        newContext:'',
        isCutZero:'',
        guanzhu:false,
        guanzhuInfo:Object,
        newtest:'',
        newStyle:'',
        lastMoney:false,
        newBorder:'',
        cutFree:false,
        changeMoney:false,
        xixi:'',
        haha:'',
        biubiu:'',
        showMoney:false,
        luelue:'',
        pNum:false,
        pNum2:true,
        num:0,
        s:'',
        bibibi:'',
        value:[],
        // randcut:[],
        sureText:'确定',
        tag:0,
        tag2:0,
        moneyMax:'',
        moneyMin:'',
        noShow:false,
        noshowTwo:false,
        newMax:false,
        icon:Number,
        zero:true
      }
    },
    computed:{
      ticket(){
        return this.$store.state.getTicket;
      }
    },
    components:{
      "v-swiper":Swiper,
      "v-context":Context,
      "v-three":Three,
      "v-space":Space,
      "v-assess":Assess,
      "v-link":Link,
      "v-guess":Guess,
      "v-imgDetail":ImgDetail
    },
    methods: {
      yep(){
        if(this.pNum2==true){
          this.$router.push({path:'/newOrder',query:{
              'iscut':1,
              'headImg':this.shopGroup.headImg,
              'name':	this.shopGroup.name,
              'buy_num':this.buy_num,
              'shopImg':this.defalutSku.pro_img,
              'price_max': this.randcut[0].cutMoney,
              'price_min':this.randcut[0].cutMoney,
              'pro_stock':this.defalutSku.pro_stock,
              'title':this.data.baseInfo.title,
              'spec':this.checkSku,
              'type':this.$route.params.type,
              'sku_id':this.skuId,
              'cutid':"",
              'delivery_price':this.delivery_price,
              'isCutZero':this.data.baseInfo.isCutZero,

            }})
        }else{
          this.$router.push({path:'/newOrder',query:{
              'iscut':1,
              'headImg':this.shopGroup.headImg,
              'name':	this.shopGroup.name,
              'buy_num':this.buy_num,
              'shopImg':this.defalutSku.pro_img,
              'price_max': this.biubiu,
              'price_min':this.biubiu,
              'pro_stock':this.defalutSku.pro_stock,
              'title':this.data.baseInfo.title,
              'spec':this.checkSku,
              'type':this.$route.params.type,
              'sku_id':this.skuId,
              'cutid':"",
              'delivery_price':this.delivery_price,
              'isCutZero':this.data.baseInfo.isCutZero,

            }})
        }
      },
      elect(){
        this.cutFree=false;
        this.changeMoney=true;
        this.showTem = true
      },
      Bback(){
        this.showTem = false;
        this.showTems = false;
        this.test = false;
        this.guanzhu = false;
        this.cutFree = false;
        this.changeMoney = false;
        this.s=2;
        this.lastMoney = false;
        this.noshowTwo = false;
        this.tag = 0;
        this.tag2 = 0;
        this.newMax = false;
      },
      tabCredit($event) {
        this.newMax = true;
        this.tag = 1;
        var that = this;
        if(that.twoSpec.name==''){
          this.tag2 = 1
        }
        var _self=this;
        var e=$event.currentTarget;
        var ehtml=$event.currentTarget.innerHTML;
        this.checkSku='';
        for(var i=0;i<this.$refs.onelist.length;i++){
          if(this.$refs.onelist[i]["innerText"]==ehtml){
            this.$refs.onelist[i].className='change',
              this.checkSku=this.$refs.onelist[i]["innerText"]
          }else{
            this.$refs.onelist[i].className='nochange'
          }
        }
        //判断组合之后的库存
        const obj =this.skuList;
        var that = this;
        var texts=that.checkSku+' '+that.checkSkuList;
        var texts2 = that.checkSku;
        var stock;
        var moneyMax;
        var moneyMin;
        for(var j in obj){
          if(texts==obj[j].value){
            if(that.icon ==1){
              that.lastMoney = false;
            }else{
              that.lastMoney = true;
            }
            that.noshowTwo = true;
            stock= obj[j].pro_stock;
            moneyMax=obj[j].price_max;
            moneyMin=obj[j].price_min;
            that.defalutSku.pro_img = obj[j].pro_img;
          }else if(texts2==obj[j].value){
            that.noshowTwo = true;
            if(that.icon ==1){
              that.lastMoney = false;
            }else{
              that.lastMoney = true;
            }
            stock= obj[j].pro_stock;
            moneyMax=obj[j].price_max;
            moneyMin=obj[j].price_min;
            that.defalutSku.pro_img = obj[j].pro_img;
          }
        }
        this.moneyMin = moneyMin;
        this.moneyMax = moneyMax;
        if(stock=='0'){
          that.sureText = '暂时无货';
          that.bibibi = 'color:#646464;background:#e6e6e6';
        }else{
          that.sureText = '确定';
          that.bibibi = '';
        }
      },
      twoCredit($event) {
        this.tag2 = 1;
        var _self=this;
        var e=$event.currentTarget;
        var ehtml=$event.currentTarget.innerHTML;
        this.checkSkuList='';
        //this.checkSku='';
        for(var i=0;i<this.$refs.twolist.length;i++){
          if(this.$refs.twolist[i]["innerText"]==ehtml){
            this.$refs.twolist[i].className='change',
              this.checkSkuList=this.$refs.twolist[i]["innerText"]
          }else{
            this.$refs.twolist[i].className='nochange'
          }
        }
        const obj =this.skuList;
        var that = this;
        var texts=that.checkSku+' '+that.checkSkuList;
        var texts2 = that.checkSku;
        var stock;
        var moneyMax;
        var moneyMin;
        for(var j in obj){
          if(texts==obj[j].value){
            if(that.icon ==1){
              that.lastMoney = false;
            }else{
              that.lastMoney = true;
            }
            that.noshowTwo = true
            stock= obj[j].pro_stock;
            moneyMax=obj[j].price_max;
            moneyMin=obj[j].price_min;
            that.defalutSku.pro_img = obj[j].pro_img;
          }else if(texts2==obj[j].value){
            if(that.icon ==1){
              that.lastMoney = false;
            }else{
              that.lastMoney = true;
            }
            that.noshowTwo = true
            stock= obj[j].pro_stock;
            moneyMax=obj[j].price_max;
            moneyMin=obj[j].price_min;
            that.defalutSku.pro_img = obj[j].pro_img;
          }
        }
        this.moneyMin = moneyMin;
        this.moneyMax = moneyMax;
        if(stock=='0'){
          that.sureText = '暂时无货';
          that.bibibi = 'color:#646464;background:#e6e6e6';
        }else{
          that.sureText = '确定';
          that.bibibi = '';
        }
      },
      addNum(){
        this.buy_num++;
      },
      goBack(){
        this.popupVisible = false;
        this.lastMoney = false;
        this.noShow = false;
        this.tag = 0;
        this.tag2 = 0;
        this.newMax = false;
      },
      reduceNum(){
        if(this.buy_num==1){
          this.buy_num=1
        }else{
          this.buy_num--;
        }
      },
      btnUp() {
        this.popupVisible = true;
        this.checkSku='';
        this.checkSkuList='';
        this.skuId=this.defalutSku.sku_id;
        for(var i in this.defalutSku){
          this.checkSku=this.defalutSku["value"]
        }
        for(var j in this.$refs.onelist){
          if(this.$refs.onelist[j].innerHTML==this.checkSku){
            this.$refs.onelist[j].className='change'
          }else{
            this.$refs.onelist[j].className='nochange'
          }
        }
        for(var a in this.$refs.twolist){
          if(this.$refs.twolist[a].innerHTML==this.checkSkuList){
            this.$refs.twolist[a].className='change'
          }else{
            this.$refs.twolist[a].className='nochange'
          }
        }
      },
      buyNow(){
        this.icon = 1;
        this.lastMoney = false;
        this.cuttype='buy';
        this.btnUp();
        this.noShow = false;
        this.newBorder='';
        this.checkSku = '';
        this.checkSkuList='';
        this.newMax = false;
        this.noshowTwo = false;
      },
      goCut(){
        this.icon = 2;
        this.newMax = false;
        this.lastMoney = false;
        this.cuttype='cut';
        this.btnUp();
        this.noShow = true;
        this.newBorder='';
        this.noshowTwo = false;
      },
      goSubhome(){
        this.$router.push('/home/index/00')
      },
      goCutFree(item,index){
        this.showMoney = true;
        this.cutFree = true;
        this.changeMoney = false;
        this.xixi=index;
        this.haha=item;
        this.biubiu=item.cutMoney;
        this.pNum=true;
        this.pNum2=false;
        this.num=index
      },
      buy(){
        if(this.tag ==0||this.tag2 ==0){
          return false;
        }
        if(this.sureText == '暂时无货'){
          return false;
        }
        if(this.isCutZero==3){
          this.showTem = true;
          this.cutFree = true;
        }
        if(this.cuttype=='buy'){
          function cloneObj(from) {
            return Object.keys(from)
              .reduce((obj, key) => (obj[key] = clone(from[key]), obj), {});
          }
          function cloneArr(from) {
            return from.map((n) => clone(n));
          }
          function clone(from) {
            if (from instanceof Array) {
              return cloneArr(from);
            } else if (from instanceof Object) {
              return cloneObj(from);
            } else {
              return (from);
            }
          }
          //判断组合之后的库存
          const obj =this.skuList;
          var that = this;
          var texts = that.checkSku+' '+that.checkSkuList;
          var texts2 = that.checkSku;
          var stock;
          var skuId;
          var priceMax;
          var priceMin;
          for(var j in obj){
            if(texts==obj[j].value||texts2==obj[j].value){
              stock= obj[j].pro_stock;
              skuId = obj[j].sku_id;
              priceMax = obj[j].price_max;
              priceMin = obj[j].price_min;
            }
          }
          if(stock=='0'){
            return false;
            that.sureText = '暂时无货';
            that.bibibi = 'color:#646464;background:#e6e6e6';
            // var that=this;
            // this.newContext = '该商品规格没有库存啦';
            // this.showTem=true;
            // this.showTems=true;
            // this.test=true;
          }else{
            this.$router.push({path:'/newOrder',query:{
                'iscut':1,
                'headImg':this.shopGroup.headImg,
                'name':	this.shopGroup.name,
                'buy_num':this.buy_num,
                'shopImg':this.defalutSku.pro_img,
                'price_max':priceMax,
                'price_min':priceMin,
                'pro_stock':this.defalutSku.pro_stock,
                'title':this.data.baseInfo.title,
                'spec':' '+this.checkSku+' '+this.checkSkuList,
                'type':this.$route.params.type,
                'sku_id':skuId,
                'cutid':"",
                'delivery_price':this.delivery_price,
                'isCutZero':this.data.baseInfo.isCutZero,
                'tag':1
              }})
          }
        }else if(this.cuttype=='cut'){
          function cloneObj(from) {
            return Object.keys(from)
              .reduce((obj, key) => (obj[key] = clone(from[key]), obj), {});
          }
          function cloneArr(from) {
            return from.map((n) => clone(n));
          }
          function clone(from) {
            if (from instanceof Array) {
              return cloneArr(from);
            } else if (from instanceof Object) {
              return cloneObj(from);
            } else {
              return (from);
            }
          }
          const obj =this.skuList;
          const obj2 = clone(obj);
          this.checkSku='';
          for(var j in this.$refs.onelist){
            if(this.$refs.onelist[j].className=='change'){
              this.checkSku=this.$refs.onelist[j]["innerHTML"]
            }
          }
          for(var i in obj2){
            if(obj2[i]['value']== this.checkSku){
              this.skuId=obj2[i]["sku_id"]
            }else{
            }
          }
          //拿到skuId
          const objs =this.skuList;
          var that = this;
          var textOne=that.checkSku+' '+that.checkSkuList;
          var textsTwo =that.checkSku;
          var skuIdCut;
          for(var j in objs){
            if(textOne==objs[j].value){
              skuIdCut = objs[j].sku_id;
            }else if(textsTwo==obj[j].value){
              skuIdCut = objs[j].sku_id;
            }
          }
          if(this.isCutZero==1){
            var that = this;
            var value=JSON.stringify({
                "sku_id":skuIdCut,
                "buy_num":this.buy_num,
                "token":localStorage.getItem('token')}),
              key=demo(value);
            axios.post('/Home/cut/PushCut',{
              value:value,
              key:key,
              ticket:this.ticket
            },config)
              .then(function(response) {
                this.$store.commit('increment',response.data.ticket);
                if(response.data.code==200){
                  this.$router.push('/oneKan/'+response.data.data.shareid)
                }else if(response.data.code==201){
                  this.showTem=true;
                  this.guanzhu=true;
                  this.guanzhuInfo=response.data.data;
                }else{
                  var that=this;
                  that.newContext=response.data.msg;
                  that.showTem=true;
                  that.showTems=true;
                  that.test=true;
                }
              }.bind(this))
              .catch(function (error) {
                console.log(error);
              });
          }
          if(this.isCutZero==2){
            var that = this;
            var value=JSON.stringify({
                "sku_id":skuIdCut,
                "buy_num":this.buy_num,
                "token":localStorage.getItem('token')}),
              key=demo(value);
            axios.post('/Home/cut/PushCut',{
              value:value,
              key:key,
              ticket:this.ticket
            },config)
              .then(function(response) {
                this.$store.commit('increment',response.data.ticket);
                if(response.data.code==200){
                  if(this.isCutZero==1){
                    this.$router.push('/oneKan/'+response.data.data.shareid)
                  }else if(this.isCutZero==2){
                    this.$router.push('/threekan/'+response.data.data.shareid)
                  }
                }else if(response.data.code==201){
                  this.showTem=true;
                  this.guanzhu=true;
                  this.guanzhuInfo=response.data.data;
                }else{
                  var that=this;
                  that.newContext=response.data.msg;
                  that.showTem=true;
                  that.showTems=true;
                  that.test=true;
                }
              }.bind(this))
              .catch(function (error) {
                console.log(error);
              });
          }
        }
      },
      collection(){
        this.flag = 2;
        var value=JSON.stringify({"type":1,"valueId":this.baseInfo.spu_id,"token":localStorage.getItem('token')}),
          key=demo(value);
        axios.post('/Home/Collection/UpdateCollection',{
          value:value,
          key:key,
          ticket:this.ticket
        },config)
          .then(function(response) {
            if(response.data.data.status==1){
              this.isCollection=true;
              this.$store.commit('increment',response.data.ticket);
            }else{
              this.isCollection=false;
              this.$store.commit('increment',response.data.ticket);
            }

          }.bind(this))
          .catch(function (error) {
            console.log(error);
          });
      },
      shareInit(pro_id,type){
        var _self=this;
        var link='/newDetail/'+pro_id+'/'+type;
        var newLink=link.replace(/\//g,'*');
        var obj={
          title:'【砍好货】:'+_self.data.baseInfo.title,
          desc:_self.data.baseInfo.title,
          link:newLink,
          imgUrl:this.imgGroup[0]
        }
        share(obj);
      },
      GetProDetails(pro_id,type){
        var value=JSON.stringify({"pro_id":pro_id,"type":type,"token":localStorage.getItem('token')}),
          key=demo(value);
        axios.post('/Home/category/GetProDetails',{
          value:value,
          key:key,
          ticket:this.ticket
        },config)
          .then(function(response) {
            const data = response.data.data;
            this.Group = data.remarkGroup;
            this.data = data;
            this.imgGroup = data.imgGroup;
            this.shopGroup = data.shopGroup;
            this.tagGroup = data.tagGroup;
            this.detailsGroup = data.detailsGroup;
            this.skuList=data.skuList;
            this.proStand=data.proStand;
            this.oneSpec = data.proStand.oneSpec;
            this.twoSpec = data.proStand.twoSpec;
            this.defalutSku.pro_img=data.skuList[0].pro_img;
            this.skuId=this.defalutSku.sku_id;
            this.money=data.baseInfo.money;
            this.baseInfo=data.baseInfo;
            this.pro_spu=data.remarkGroup.pro_spu;
            this.delivery_price=data.baseInfo.delivery_price;
            this.isOnline=data.baseInfo.isOnline;
            this.isCutZero=data.baseInfo.isCutZero;
            this.randcut =data.randCutInfo;
            this.min_price= data.baseInfo.min_price;
            if(this.isCutZero=='2'){
              this.zero = false;
            }else{
              this.zero = true
            }
            // if(data.randCutInfo!=''){
            //   this.thepk=data.randCutInfo[1].peopleNum;
            //   alert('1');
            // }
            // this.cutNum = response.data.data.randCutInfo.cut_num ;
            // this.cutMoney =response.data.data.randCutInfo.cut_money;
            if(response.data.data.baseInfo.isFocus==1){
              this.isCollection=true;
              this.$store.commit('increment',response.data.ticket);
            }else{
              this.isCollection=false;
              this.$store.commit('increment',response.data.ticket);
            }
            if(response.data.data.baseInfo.isOnline==1){
              this.inStock=true
            }else{
              this.inStock=false
            }
            this.shareInit(pro_id,type);
          }.bind(this))
          .catch(function (error) {
            console.log(error);
          });
      },
      gozhichi(){
        window.location.href='https://www.sobot.com/chat/h5/index.html?sysNum=8aa3c6e204e843ce93d80c7b9208d4e6'
      },
      photoSwiperInit(imgs){
        var openPhotoSwipe = function() {
          var pswpElement = document.querySelectorAll('.pswp')[0];
          // build items array
          var items=[];
          items.push({"src":imgs,"w":964,"h":1024})
          // define options (if needed)
          var options = {
            // history & focus options are disabled on CodePen
            history: false,
            focus: false,
            showAnimationDuration: 0,
            hideAnimationDuration: 0
          };
          var gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
          gallery.init();
        };
        openPhotoSwipe();
      }
    },
    created(){
      this.s=this.$route.query.show;
      this.proId=this.$route.params.pro_id;
      this.type=this.$route.params.type;
      this.GetProDetails(this.proId,this.type);
    },
    activated(){
      MtaH5.init({
        "sid":'500594815',
        "cid":'500595819',
        "autoReport":0,
        "senseHash":0,
        "senseQuery":0,
        "performanceMonitor":0,
        "ignoreParams":[]
      });
      MtaH5.pgv();
    },
    deactivated () {
      this.$destroy(true)
    },
    mounted() {

    }
  }



</script>

<style>
</style>